package scau.zzf.entity;

import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import scau.zzf.base.beanvalidator.ValidObject;
import scau.zzf.base.common.Unique;

import javax.persistence.Table;
import javax.validation.constraints.Size;
import java.util.Date;

/**
 * Created by AutoSSM.
 */
public class User extends Unique {
    @ApiModelProperty("用户名")
    @Length(min =6,max = 20,message = "用户名长度必须大于6小于20",groups = ValidObject.class)
    private String username;

    private String password;

    private String salt;

    private Long createBy;

    private String createName;

    private String phone;

    private Date freeTime;

    @ApiModelProperty("0 超级管理员 1普通管理员")
    @Range(min= -1,max=1,message = "userType不能超过1",groups = ValidObject.class)
    private Integer userType;

    public static final String  USERNAME = "username";
    public static final String PASSWORD = "password";
    public static final String SALT = "salt";
    public static final String CREATE_BY= "createBy";
    public static final String CREATE_NAME = "createName";
    public static final String SHOP_NAME = "shopName";
    public static final String PHONE = "phone";
    public static final String USER_TYPE = "userType";
    public static final String FREE_TIME = "freeTime";

    public User() {
    }

    public User(String username, String password, String salt, Long createBy, String createName, String shopName, String phone) {
        this.username = username;
        this.password = password;
        this.salt = salt;
        this.createBy = createBy;
        this.createName = createName;
        this.phone = phone;

    }

    public Date getFreeTime() {
        return freeTime;
    }

    public void setFreeTime(Date freeTime) {
        this.freeTime = freeTime;
    }

    public Integer getUserType() {
        return userType;
    }

    public void setUserType(Integer userType) {
        this.userType = userType;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public Long getCreateBy() {
        return createBy;
    }

    public void setCreateBy(Long createBy) {
        this.createBy = createBy;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }


    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }



    public String getCredentialsSalt() {
        return salt+username;
    }

}
